package com.agentai.framework.common.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Swagger配置
 *
 */
@Configuration
public class SwaggerConfig {

    @Bean
    public GroupedOpenApi userApi() {
        String[] paths = {"/sys/**"};
        String[] packagedToMatch = {"com.agentai.system"};
        return GroupedOpenApi.builder().group("系统模块")
                .pathsToMatch(paths)
                .packagesToScan(packagedToMatch).build();
    }

    @Bean
    public GroupedOpenApi monitorApi() {
        String[] paths = {"/monitor/**"};
        String[] packagedToMatch = {"com.agentai.monitor"};
        return GroupedOpenApi.builder().group("系统监控模块")
                .pathsToMatch(paths)
                .packagesToScan(packagedToMatch).build();
    }

    @Bean
    public GroupedOpenApi messageApi() {
        String[] paths = {"/message/**"};
        String[] packagedToMatch = {"com.agentai.message"};
        return GroupedOpenApi.builder().group("短信模块")
                .pathsToMatch(paths)
                .packagesToScan(packagedToMatch).build();
    }

    @Bean
    public GroupedOpenApi backBuinessApi() {
        String[] paths = {"/back/buiness/**"};
        String[] packagedToMatch = {"com.agentai.buiness.back"};
        return GroupedOpenApi.builder().group("业务模块-管理后台")
                .pathsToMatch(paths)
                .packagesToScan(packagedToMatch).build();
    }

    @Bean
    public OpenAPI customOpenAPI() {
        Contact contact = new Contact();
        contact.setName("agentai@126.com");

        return new OpenAPI().info(new Info()
                .title("AgentAi")
                .description("agentai")
                .contact(contact)
                .version("1.0")
                .termsOfService("https://agentai.com")
                .license(new License().name("MIT")
                        .url("https://agentai.com")));
    }

}
